<?php

namespace app\admin\controller;

use app\common\controller\AdminController;
use app\common\enum\order\OrderStatus;
use app\common\service\annotation\ControllerAnnotation;
use app\common\service\annotation\NodeAnnotation;
use app\company\model\CompanyOrder;
use think\App;

/**
 * @ControllerAnnotation(title="统计管理")
 */
class Statistics extends AdminController
{
    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    /**
     * @NodeAnnotation(title="销售数据动态")
     */
    public function sale()
    {
        $get = $this->request->get();
        $this->request->get('time', 'yesterday');
        // 销售总额
        $total_sale_money = $this->getSaleOrderInfo($time,$orderType);
    }

    private function getSaleOrderInfo($time)
    {
        $sql = new CompanyOrder();
        if ($time == 'yesterday') {
            $sql->whereTime('create_time', 'yesterday');
        }elseif ($time == 'week'){
            $sql->whereTime('create_time', 'week');
        }elseif ($time == 'month') {
            $sql->whereTime('create_time', 'month');
        }
        return $sql->where('order_status',OrderStatus::FINISH)->where('order_type',)
                   ->sum('total_money');
    }
}